import { defineStore } from 'pinia'
import { roleList } from '../utils/trueType'

export const useRoleListStore = defineStore('roleList', {
    state: () => ({
        roleList: [
            {
                id: '',
                roleName: '权限管理',
                rolekey: 'permission',
                status: 1,
                time: ''
            }
        ] as roleList[],
        pageSize:5,
        pageNum:1,
        total:0,
        loading: false,
        selectedIds: <string[]>([]),
    }),
    actions: {
        setPermissionList(data: roleList[]) {
            this.roleList = data
        },
        changeLoading(){
            this.loading = !this.loading
            setTimeout(() => {
                this.loading = !this.loading
            }, 500);
        },
        addSelectedIds(id: string) {
            if (this.selectedIds.includes(id)) {
                this.selectedIds.splice(this.selectedIds.indexOf(id), 1)
            } else {
                this.selectedIds.push(id)
            }
        },
    },
    getters: {

    },
}
)